package com.zjun.demo;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zjun.util.RedisLuaHelper;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class LuaService {

	
	@Resource
	private RedisLuaHelper redisLuaHelper;
	
	
	@SuppressWarnings("unchecked")
	public List<Long> decrby(String key, int num) {
		log.info("key: {}、num: {}", key, num);
		return redisLuaHelper.runLua("lua/decrby.lua", List.class, Arrays.asList(key), new Integer[] {num});
	}
	
	
	public String decrbyJson(String key, int num) {
		log.info("key: {}、num: {}", key, num);
		return redisLuaHelper.runLuaString("lua/decrbyJson.lua", Arrays.asList(key), new String[] {num+""});
//		return redisLuaHelper.runLuaString("lua/zStockTakeOutRes.lua", Arrays.asList(key), new String[] {num+""});
	}
	
}
